<%
'#################################################################################
'## UnWritten Open Source Blog Engine
'#################################################################################
'## Copyright (C) 2008 Luigi Violin
'##
'## This program is free software: you can redistribute it and/or modify
'## it under the terms of the GNU General Public License as published by
'## the Free Software Foundation, either version 2 of the License, or
'## (at your option) any later version.
'##
'## This program is distributed in the hope that it will be useful,
'## but WITHOUT ANY WARRANTY; without even the implied warranty of
'## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
'## GNU General Public License for more details.
'##
'## You should have received a copy of the GNU General Public License
'## along with this program.  If not, see <http://www.gnu.org/licenses/>.
'##
'## You can obtain support from our forums at:
'##     <http://www.unwrittenblog.com/forums/>
'## Contact the author directly:
'##     <zaamit@hotmail.com/>
'##
'#################################################################################
%>
<!--#include virtual="/config.asp"-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>UnWritten Open Souce Blog Engine | Installation</title>
<link type="text/css" rel="stylesheet" href="/admin/style.css" />
</head>
<body>
<div id="top_admin"><h1>UnWritten Open Source Blog Engine | Installation</h1></div>
<div id="container">
<div id="header"><div id="menu"><div id="inner">
	Step 1 | <strong>Step 2</strong> | Step 3
</div></div></div><div id="main"><div id="inner">
<h1>Ooops...</h1>
<%
Dim dbConn
set dbConn = Server.CreateObject("ADODB.Connection")
on error resume next
dbConn.open "Driver={MySQL ODBC 3.51 Driver};Server=" & cfg_serverip & ";Port=" & cfg_port & ";Database=" & cfg_db & ";User=" & cfg_user & ";Password=" & cfg_pass & ";Option=3;"
 
dbConn.execute"CREATE TABLE `" & db_prefix & "badwords` (`id` int(11) NOT NULL auto_increment,`text` varchar(50) default NULL,`replace_text` varchar(50) default NULL,PRIMARY KEY  (`id`))ENGINE=InnoDB DEFAULT CHARSET=latin1;"
dbConn.execute"CREATE TABLE `" & db_prefix & "comments` (`id` int(11) NOT NULL auto_increment,`postid` int(11) default NULL,`text` varchar(255) default NULL,`author_id` int(11) default NULL,`author_name` varchar(50) default NULL,`author_email` varchar(50) default NULL,`author_ip` varchar(50) default NULL,`author_url` varchar(50) default NULL,`date` datetime default NULL,`date_gmt` datetime default NULL,`status` tinyint(3) default NULL,PRIMARY KEY  (`id`)) ENGINE=InnoDB DEFAULT CHARSET=latin1;"
dbConn.execute"CREATE TABLE `" & db_prefix & "links` (`id` int(11) NOT NULL auto_increment,`text` varchar(255) default NULL,`image` varchar(255) default NULL,`url` varchar(255) default NULL,`date` datetime default NULL,`date_gmt` datetime default NULL,`clicks` int(11) default NULL,`status` tinyint(3) default NULL,PRIMARY KEY  (`id`)) ENGINE=InnoDB DEFAULT CHARSET=latin1;"
dbConn.execute"CREATE TABLE `" & db_prefix & "options` (`id` int(11) NOT NULL auto_increment,`name` varchar(255) default NULL,`root` varchar(255) default NULL,`description` varchar(255) default NULL,`keywords` varchar(255) default NULL,`add_meta` varchar(255) default NULL,`theme` varchar(50) default NULL,`custom_css` varchar(255) default NULL,`posts_perpage` tinyint(3) default '8',`comments_perpage` tinyint(3) default NULL,`logo_url` varchar(255) default NULL,`enabled` tinyint(3) default NULL,`disabled_text` varchar(255) default NULL,`copyright` varchar(255) default NULL,`use_nice_urls` tinyint(3) default '0',`use_custom_home` tinyint(3) default '0',PRIMARY KEY  (`id`)) ENGINE=InnoDB DEFAULT CHARSET=latin1;"
dbConn.execute"CREATE TABLE `" & db_prefix & "polls` (`id` int(11) NOT NULL auto_increment,`title` varchar(255) default NULL,`intro` varchar(255) default NULL,`date` datetime default NULL,`date_gmt` varchar(255) default NULL,`home` tinyint(3) default NULL,`status` tinyint(3) default NULL,`expire_date` datetime default NULL,`expire_date_gmt` datetime default NULL,PRIMARY KEY  (`id`)) ENGINE=InnoDB DEFAULT CHARSET=latin1;"
dbConn.execute"CREATE TABLE `" & db_prefix & "polls_options` (`id` int(11) NOT NULL auto_increment,`pollid` int(11) default NULL,`text` varchar(255) default NULL,`votes` int(11) default NULL,PRIMARY KEY  (`id`)) ENGINE=InnoDB DEFAULT CHARSET=latin1;"
dbConn.execute"CREATE TABLE `" & db_prefix & "posts` (`id` int(11) NOT NULL auto_increment,`author` int(11) default NULL,`pdate` datetime default NULL,`pdate_gmt` datetime default NULL,`title` varchar(255) character set latin1 default NULL,`content` longtext character set latin1,`excerpt` varchar(255) character set latin1 default NULL,`ent_name` varchar(255) character set latin1 default NULL,`modified` datetime default NULL,`modified_gmt` datetime default NULL,`icon` varchar(255) character set latin1 default NULL,`views` int(11) default NULL,`publish_status` tinyint(3) default NULL,`ratingsum` tinyint(3) default NULL,`ent_type` tinyint(3) default NULL,`category` varchar(50) character set latin1 default NULL,PRIMARY KEY  (`id`)) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci;"
dbConn.execute"CREATE TABLE `" & db_prefix & "posttags` (`id` int(11) NOT NULL auto_increment,`tagid` int(11) default NULL,`postid` int(11) default NULL,PRIMARY KEY  (`id`)) ENGINE=InnoDB DEFAULT CHARSET=latin1;"
dbConn.execute"CREATE TABLE `" & db_prefix & "ratings` (`id` int(11) NOT NULL auto_increment,`user` int(11) default NULL,`post` int(11) default NULL,`rate` tinyint(3) default NULL,PRIMARY KEY  (`id`)) ENGINE=InnoDB DEFAULT CHARSET=latin1;"
dbConn.execute"CREATE TABLE `" & db_prefix & "tags` (`id` int(11) NOT NULL auto_increment,`text` varchar(50) default NULL,PRIMARY KEY  (`id`)) ENGINE=InnoDB DEFAULT CHARSET=latin1;"
dbConn.execute"CREATE TABLE `" & db_prefix & "users` (`id` int(11) NOT NULL auto_increment,`login` varchar(50) default NULL,`password` varchar(50) default NULL,`nick` varchar(50) default NULL,`email` varchar(50) default NULL,`url` varchar(255) default NULL,`bio` text,`avatar` varchar(255) default NULL,`level` tinyint(3) default NULL,`msn` varchar(255) default NULL,`skype` varchar(255) default NULL,`ip` varchar(50) default NULL,`lastip` varchar(50) default NULL,`member_since` datetime default NULL,`last_visit` datetime default NULL,`activation_key` varchar(255) default NULL,`ustatus` tinyint(3) default NULL,PRIMARY KEY  (`id`)) ENGINE=InnoDB DEFAULT CHARSET=latin1;"

dbConn.execute"INSERT INTO `" & db_prefix & "options` VALUES (1,'Your site name','http://yoursite.com','Your site description','your,site,keywords','','default',NULL,8,0,'',1,'Site is under maintenance. We will be back in a few minutes.','Copyright (C) 2008 - Yoursite.com',0,0);"
dbConn.execute"INSERT INTO `" & db_prefix & "users` VALUES (1,'admin','752D66D9A4A484DEC30A85FEBD70F4231BF73431','admin','webmaster@yoursite.com',NULL,NULL,NULL,10,NULL,NULL,'127.0.0.1','127.0.0.1','2008-08-08 08:08:08','2008-08-08 08:08:08',NULL,1);"
dbConn.execute"INSERT INTO `" & db_prefix & "comments` VALUES (1,4,'<p>Sample comment, feel free to delete me.</p>',1,'admin','webmaster@yoursite.com','10.37.129.3','','2008-08-08 08:08:08','2008-08-08 08:08:08',1);"
dbConn.execute"INSERT INTO `" & db_prefix & "posts` VALUES (1,1,'2008-08-08 08:08:08','2008-08-08 08:08:08','About','<p>About page</p>','About page','about','2008-08-08 08:08:08','2008-08-08 08:08:08','',0,1,0,2,NULL);"
dbConn.execute"INSERT INTO `" & db_prefix & "posts` VALUES (2,1,'2008-08-08 08:08:08','2008-08-08 08:08:08','Contact','<p>Contact page</p>','Contact page','contact','2008-08-08 08:08:08','2008-08-08 08:08:08','',0,1,0,2,NULL);"
dbConn.execute"INSERT INTO `" & db_prefix & "posts` VALUES (3,1,'2008-08-08 08:08:08','2008-08-08 08:08:08','Home','<p>Custom home contents</p>','Custom home contents','home','2008-08-08 08:08:08','2008-08-08 08:08:08','',0,1,0,2,NULL);"
dbConn.execute"INSERT INTO `" & db_prefix & "posts` VALUES (4,1,'2008-08-08 08:08:08','2008-08-08 08:08:08','Welcome!','<p>This is a sample blog post, you can edit or delete it now.</p>\r\n<p>Happy blogging!</p>','This is a sample blog post, you can edit or delete it now.\r\nHappy blogging!','welcome','2008-08-08 08:08:08','2008-08-08 08:08:08','',0,1,0,1,NULL);"

if err > 0 then
	Response.Write "Cannot make connection to your MySql database.<br /><br />Please check that you have a file named <i>config.asp</i> in your site root directory and that it is properly configured.<br><br><a href=""step2.asp"">Try again</a>"
	else
		Response.Redirect "step3.asp"
end if
%>
</div></div><div id="footer"><div id="inner">
<a href="http://www.unwrittenblog.com">UnWritten // Open Source Blog Engine</a> - This program is free software; you can redistribuite it and/or modify it under the terms of the GNU/General Pubblic License.
</div></div></div></body>
</html>